#include "CProgressbar.h"

CProgressbar::CProgressbar() {
  m_hProgressbar = NULL;
}

void CProgressbar::SetHandle(HWND hProgressbar) {
  m_hProgressbar = hProgressbar;
}

HWND CProgressbar::GetHandle() {
  return m_hProgressbar;
}

HWND CProgressbar::Create(DWORD dwStyle, int x, int y, int w, int h, UINT nID,
    HWND hParent) {
  m_hProgressbar = ::CreateWindow(PROGRESS_CLASS, NULL, WS_VISIBLE | WS_CHILD |
      dwStyle, x, y, w, h, hParent, (HMENU)(long long)nID, NULL, NULL);
  return m_hProgressbar;
}

BOOL CProgressbar::Destroy() {
  return ::DestroyWindow(m_hProgressbar);
}

INT CProgressbar::SetState(int nState) {
  return ::SendMessage(m_hProgressbar, PBM_SETSTATE, nState, 0);
}

INT CProgressbar::GetState() {
  return ::SendMessage(m_hProgressbar, PBM_GETSTATE, 0, 0);
}

INT CProgressbar::SetRange(int nMinRange, int nMaxRange) {
  return ::SendMessage(m_hProgressbar, PBM_SETRANGE, 0,
      MAKELPARAM(nMinRange, nMaxRange));
}

INT CProgressbar::GetRange(BOOL bWhichLimit, PPBRANGE ppBRange) {
  return ::SendMessage(m_hProgressbar, PBM_GETRANGE, bWhichLimit,
      (LPARAM)ppBRange);
}

INT CProgressbar::SetPos(int nNewPos) {
  return ::SendMessage(m_hProgressbar, PBM_SETPOS, nNewPos, 0);
}

INT CProgressbar::GetPos() {
  return ::SendMessage(m_hProgressbar, PBM_GETPOS, 0, 0);
}

INT CProgressbar::DeltaPos(int nIncrement) {
  return ::SendMessage(m_hProgressbar, PBM_DELTAPOS, nIncrement, 0);
}

INT CProgressbar::SetStep(int nStepInc) {
  return ::SendMessage(m_hProgressbar, PBM_SETSTEP, nStepInc, 0);
}

INT CProgressbar::GetStep() {
  return ::SendMessage(m_hProgressbar, PBM_GETSTEP, 0, 0);
}

INT CProgressbar::StepIt() {
  return ::SendMessage(m_hProgressbar, PBM_STEPIT, 0, 0);
}

INT CProgressbar::SetMarquee(BOOL bState, UINT nPeriod) {
  return ::SendMessage(m_hProgressbar, PBM_SETMARQUEE, bState, nPeriod);
}

